package org.university.entity;

import io.swagger.annotations.ApiModelProperty;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.university.enums.GlobalEnums;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDate;

/**
 * @TableName student
 */
@Entity
@Table(name = "student",
        uniqueConstraints = @UniqueConstraint(name = "unique_id_name", columnNames = {"student_id", "student_name"}))
@Data
public class Student implements Serializable {

    @Id
    @NotBlank(message = "[]不能为空")
    @Size(max = 20, message = "编码长度不能超过20")
    @ApiModelProperty("")
    @Length(max = 20, message = "编码长度不能超过20")
    private String studentId;
    /**
     * 姓名
     */
    @NotBlank(message = "[姓名]不能为空")
    @Size(max = 20, message = "编码长度不能超过20")
    @ApiModelProperty("姓名")
    @Length(max = 20, message = "编码长度不能超过20")
    private String studentName;
    /**
     * 性别
     */
    @ApiModelProperty("性别")
    @Enumerated(EnumType.STRING)
    private GlobalEnums.Gender gender;
    /**
     * 出生日期
     */
    @ApiModelProperty("出生日期")
    private LocalDate birthDate;
    /**
     * 入学日期
     */
    @NotNull(message = "[入学日期]不能为空")
    @ApiModelProperty("入学日期")
    private LocalDate enrollmentDate;
    /**
     * 所属学院ID
     */
    @NotNull(message = "[所属学院ID]不能为空")
    @ApiModelProperty("所属学院ID")
    private Integer deptId;
    /**
     * 班级ID
     */
    @ApiModelProperty("班级ID")
    private Integer classId;
    /**
     * 手机号码
     */
    @Size(max = 15, message = "编码长度不能超过15")
    @ApiModelProperty("手机号码")
    @Length(max = 15, message = "编码长度不能超过15")
    private String phone;
    /**
     * 电子邮箱地址
     */
    @Size(max = 100, message = "编码长度不能超过100")
    @ApiModelProperty("电子邮箱地址")
    @Length(max = 100, message = "编码长度不能超过100")
    private String email;
    /**
     * 家庭住址
     */
    @Size(max = 100, message = "编码长度不能超过100")
    @ApiModelProperty("家庭住址")
    @Length(max = 100, message = "编码长度不能超过100")
    private String address;

    @Column(name = "deleted", columnDefinition = "tinyint(1) default 0")
    @ApiModelProperty("是否已删除")
    private Integer deleted = 0;
}
